<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
	<s:include value="common/header.jsp"></s:include>
	<link type="text/css" rel="stylesheet" href="css/jquery.realperson.css">
<!-- 	<link type="text/css" rel="stylesheet" href="css/jquery-ui-1.10.2.custom.css"> -->
<!-- 	<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.2/themes/smoothness/jquery-ui.css" /> -->
	<script type="text/javascript" src="js/lib/jquery.realperson.js"></script>
	<script type="text/javascript" src="js/lib/jquery-ui-1.10.2.custom.min.js"></script>
	<script type="text/javascript" src="js/lib/jquery.ui.datepicker-zh-TW.min.js"></script>
	<script type="text/javascript" src="js/johnDate.js"></script>
	<script src="js/lib/jquery-ui.js"></script>
	<link rel="stylesheet" href="css/jquery-ui.css" />
</head>
<script type="text/javascript">
	$(function(){
		// 把 #defaultReal 轉換成驗證碼輸入框
		// 設定驗證碼長度 10 碼
		$('#defaultReal').realperson({
			length: 10,
			regenerate: '重新產生'
		});
	});
	
	$(function() {
		$('#submit').click(function() {
			var pw = $('#password').val();
			var validate = /[0-9]+[A-Za-z]+$/;
			if(!validate.test(pw) || pw.length != 6) {
				console.log(pw);
				alert('請輸入六位英文數字');
			} else {
				console.log('ok');
			};
		});
	});
	
// 	$(function() {
// 		$.post('json/login!validateUser.do');
// 		console.log("${pageContext.request.contextPath}");
// 	});
	
	 $(function() {
		    $('#buttonTest').click(function(){
		    	$('#dialog-confirm').dialog({
			      resizable: false,
			      height:140,
			      modal: true,
			      buttons: {
			        '是': function() {
			          $(this).dialog('close');
			        },
			        '否': function() {
			          $(this).dialog('close');
			        }
			      }
		    	});
		    });
		  });
	 
	 $(function() {
		$('#buttonClose').click(function() {
			window.opener=null;      
			window.open('','_self');      
			window.close(); 
		}); 
	 });
	 
	 $(function() {
		$('#testPost').click(function() {
			var a = $('#address1').val();
			var b = $('#address2').val();
			var c = $('#address3').val();
			console.log(a);
			console.log(b);
			console.log(c);
			if(a == null || b == null || c == null) {
				alert('請輸入正確地址');
				return false;
			} else {
				var address = a+b+c;
				$.post('login!test.do', {'address': address}, function(obj) {
					console.log(obj);
				});
			}
		});
	 });
	 
	 $(function() {
		$('#forIntBtn').click(function() {
			var validateInt = /^[0-9]*$/;
			var intText = document.getElementById('int').value;
			console.log(intText);
			if(!validateInt.test(intText)) {
				alert('請輸入數字');
			}
		}); 
	 });
</script>
	<body>
		<form action="jquery.realperson.php" method="post"> 
			<p>
				<label>請輸入下面顯示的字元:</label>
				<input type="text" id="defaultReal" name="defaultReal">
			</p> 
			<p class="submit">
				<input type="submit" value="送出驗證">
			</p> 
		</form>
		
		<input id="password" type="password">
		<button id="submit">測試</button>
		
		<p>Date: <input type="text" id="date" /></p>
		
		<img src="${pageContext.request.contextPath}/validateCode.do"/>
		<button id="commit">測試</button>
<%-- 		<img src="${pageContext.request.contextPath}/images/123.jpg"/> --%>
		<div id="dialog-confirm" title="test">
			<p><span class="ui-icon ui-icon-alert" style="float: left; margin: 0 7px 20px 0;"></span>測試</p>
		</div>
		<button id="buttonTest">警告</button>
		<button id="buttonClose">關閉</button>
		<div>
			<input id=address1>
			<input id=address2>
			<input id=address3>
			<button id="testPost">post</button>
		</div>
		<div>
			<input id="int" type="text">
			<button id="forIntBtn">轉數字</button>
		</div>
	</body>
</html>